﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SeaBattle.Domain.Abstract.Services;
using SeaBattle.Domain.Entities;
using SeaBattle.Domain.Abstract;
using System.Linq;

namespace SeaBattle.Domain.Concrete.Services
{
    public class FakeGameService:IGameService
    {
        IPlayerService playerService;
        private IGameRepository gameRepository;
        

        public FakeGameService(IPlayerService playerService, IGameRepository gameRepository)
        {
            this.playerService = playerService;
            this.gameRepository = gameRepository;
        }


        public IEnumerable<Game> GetOpenedGames()
        {
            return from game in gameRepository.GetAllGames() where game.Opened orderby game.Preset select game;
        }


        public IEnumerable<Game> GetParticipantsPlayerGames(Player player)
        {
            return from game in gameRepository.GetAllGames()
                   where (player == game.Creator || player == game.Opponent)
                   orderby game.Created descending
                   select game;
        }
    }
}
